#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: henry_oulen@163.com
@file: dbutils.py
@time: 2023/10/27 18:45
@desc: 
"""

from tornado.options import options
from sqlalchemy.ext.declarative import declarative_base
# from backend.tvadmin.utils.handle_utils import base_path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from backend.conf import config

# config_file = "/".join([base_path, "/conf/env.py"])
# options.parse_config_file(config_file)
host = config.mysql.get("host")
port = config.mysql.get("port")
user = config.mysql.get("user")
password = config.mysql.get("password")
database = config.mysql.get("database")
# 数据连接url
db_url = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8mb4'.format(user, password, host, port, database)
base = declarative_base()
engine = create_engine(db_url, echo=config.sqlalchemy_echo_log)
